package com.atguigu.ssyx.search.repository;

import com.atguigu.ssyx.model.search.SkuEs;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

/**
 * @Author：tzl
 * @Date：2023/11/14 14:25
 */
public interface SkuRepository extends ElasticsearchRepository<SkuEs, Long> {

    /**
     * ES查询爆款
     * @param pageable
     * @return
     */
    Page<SkuEs> findByOrderByHotScoreDesc(Pageable pageable);

    /**
     * ES通过categoryId和wareId查询商品
     * @param categoryId
     * @param wareId
     * @param pageable
     * @return
     */
    Page<SkuEs> findByCategoryIdAndWareId(Long categoryId, Long wareId, Pageable pageable);

    /**
     * ES通过关键词和wareId查询商品
     * @param keyword
     * @param wareId
     * @param pageable
     * @return
     */
    Page<SkuEs> findByKeywordAndWareId(String keyword, Long wareId, Pageable pageable);
}
